package com.esl.model.admin;

import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

@Entity
@Table(name = "T_Project")
@Cache(usage=CacheConcurrencyStrategy.READ_ONLY)
public class Project implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = -7941242115872434975L;
	private Integer id;
	private String title;
	private String content;
	private String keytech;
	private String picurl;
	private String state;
	private Date time;
	private Integer kind;
	private String detail;
	private String temp;
	private Set<User> users = new HashSet<User>();

	public Project() {
		super();
	}

	public Project(String title, String content, String keytech, String picurl,
			String state, Date time, Integer kind, String detail,
			Set<User> users) {
		super();
		this.title = title;
		this.content = content;
		this.keytech = keytech;
		this.picurl = picurl;
		this.state = state;
		this.time = time;
		this.kind = kind;
		this.detail = detail;
		this.users = users;
	}

	@ManyToMany
	@JoinTable(name = "T_User_Project", joinColumns = { @JoinColumn(name = "p_pid") }, inverseJoinColumns = { @JoinColumn(name = "u_uid") })
	public Set<User> getUsers() {
		return users;
	}

	public void setUsers(Set<User> users) {
		this.users = users;
	}

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "p_id", unique = true, nullable = false)
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Column(name = "p_title")
	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	@Column(name = "p_content")
	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	@Column(name = "p_keytech")
	public String getKeytech() {
		return keytech;
	}

	public void setKeytech(String keytech) {
		this.keytech = keytech;
	}

	@Column(name = "p_piurl")
	public String getPicurl() {
		return picurl;
	}

	public void setPicurl(String picurl) {
		this.picurl = picurl;
	}

	@Column(name = "p_state")
	public String getState() {
		return state;
	}

	public void setState(String state) {
		this.state = state;
	}

	@Column(name = "p_time")
	public Date getTime() {
		return time;
	}

	public void setTime(Date time) {
		this.time = time;
	}

	@Column(name = "p_kind")
	public Integer getKind() {
		return kind;
	}

	public void setKind(Integer kind) {
		this.kind = kind;
	}

	@Column(name = "p_detail")
	public String getDetail() {
		return detail;
	}

	public void setDetail(String detail) {
		this.detail = detail;
	}

	@Column(name = "p_temp")
	public String getTemp() {
		return temp;
	}

	public void setTemp(String temp) {
		this.temp = temp;
	}

}
